package com.tony.mindhr.service;

import com.tony.mindhr.mapper.PositionMapper;
import com.tony.mindhr.model.Position;
import com.tony.mindhr.model.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: PositionService
 * @Auther: 皮蛋布丁
 * @Date: 2021/05/19/22:02
 * @Description:
 */
@Service
public class PositionService {

    @Autowired
    PositionMapper positionMapper;

    /**
    * @Description: getAllPositions 获取职位下拉列表
    * @Param: []
    * @return: java.util.List<com.tony.mindhr.model.Position>
    * @Author: 皮蛋布丁
    * @Date: 2021/6/14 20:47
    */
    public List<Position> getAllPositions() {
        return positionMapper.getAllPositions();
    }

    public Integer addPosition(Position position) {
        position.setEnabled(true);
        position.setCreateDate(new Date());
        return positionMapper.insertSelective(position);
    }

    /**
    * @Description: updatePositions 根据传进来的数据进行更新
    * @Param: [position]
    * @return: java.lang.Integer
    * @Author: 皮蛋布丁
    * @Date: 2021/5/19 22:27
    */
    public Integer updatePositions(Position position) {
        return positionMapper.updateByPrimaryKeySelective(position);
    }

    /**
    * @Description: deletePositionById 删除
    * @Param: [id]
    * @return: java.lang.Integer
    * @Author: 皮蛋布丁
    * @Date: 2021/5/19 22:30
    */
    public Integer deletePositionById(Integer id) {
        return positionMapper.deleteByPrimaryKey(id);
    }

    public Integer deletePositionByIds(Integer[] ids) {
        return positionMapper.deletePositionByIds(ids);
    }
}
